/**
 * Copyright (c) 2015-2017, Henry Yang 杨勇 (gismail@foxmail.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.lambkit.module.common.sql;

import cn.hutool.core.util.StrUtil;
import com.lambkit.db.PageData;
import com.lambkit.db.sql.Column;
import com.lambkit.db.sql.Columns;
import com.lambkit.db.sql.ConditionMode;
import com.lambkit.db.sql.Example;
import com.lambkit.module.common.row.Setting;
import com.lambkit.module.common.service.SettingService;

import java.io.Serializable;
import java.util.List;

/**
 * @author yangyong 
 * @website: www.lambkit.com
 * @email: gismail@foxmail.com
 * @date ${date}
 * @version 1.0
 * @since 1.0
 */

public class SettingSQL extends Columns implements Serializable {
	private static final long serialVersionUID = 1L;
	
	public static SettingSQL of() {
		return new SettingSQL();
	}
	
	public static SettingSQL by(Column column) {
		SettingSQL that = new SettingSQL();
		that.add(column);
        return that;
    }

    public static SettingSQL by(String name, Object value) {
        return (SettingSQL) create().eq(name, value);
    }

    private String orderBy;
    
    public Example example() {
    	Example example = Example.create("lk_setting", this);
    	if(StrUtil.isNotBlank(orderBy)) {
    		example.setOrderBy(orderBy);
    	}
    	return example;
    }

    public SettingSQL orderBy(String orderBy) {
    	this.orderBy = orderBy;
    	return this;
    }

    public Setting findFirst() {
        return SettingService.of().dao().findFirst(example());
    }

    public List<Setting> find() {
        return SettingService.of().dao().find(example());
    }

    public PageData<Setting> paginate(Integer pageNumber, Integer pageSize) {
        return SettingService.of().dao().paginate(pageNumber, pageSize, example());
    }

    /**
     * equals
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL eq(String name, Object value) {
    	super.eq(name, value);
        return this;
    }

    /**
     * not equals !=
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL ne(String name, Object value) {
    	super.ne(name, value);
        return this;
    }


    /**
     * like
     *
     * @param name
     * @param value
     * @return
     */

    public SettingSQL like(String name, Object value) {
    	super.like(name, value);
        return this;
    }
    
    public SettingSQL notLike(String name, Object value) {
    	super.notLike(name, value);
        return this;
    }

    /**
     * 大于 great than
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL gt(String name, Object value) {
    	super.gt(name, value);
        return this;
    }

    /**
     * 大于等于 great or equal
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL ge(String name, Object value) {
    	super.ge(name, value);
        return this;
    }

    /**
     * 小于 less than
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL lt(String name, Object value) {
    	super.lt(name, value);
        return this;
    }

    /**
     * 小于等于 less or equal
     *
     * @param name
     * @param value
     * @return
     */
    public SettingSQL le(String name, Object value) {
    	super.le(name, value);
        return this;
    }
    
    public SettingSQL isnull(String name) {
    	super.isnull(name);
        return this;
    } 

    public SettingSQL notNull(String name) {
    	super.notNull(name);
        return this;
    } 
    
    public SettingSQL empty(String name) {
    	super.empty(name);
        return this;
    } 
    
    public SettingSQL notEmpty(String name) {
    	super.notEmpty(name);
        return this;
    } 
    
    public SettingSQL add(Column column) {
    	super.add(column);
    	return this;
    }
    
    /**************************/
	
	public void addCriterion(String name, Object value, ConditionMode logic, String property, String typeHandler, String valueType) {
		 if (value == null) {
			 throw new RuntimeException("Value for " + property + " cannot be null");
		 }
		 add(Column.create(name, value, logic, typeHandler, valueType));
	}
   
	public void addCriterion(String name, Object value1, Object value2, ConditionMode logic, String property, String typeHandler, String valueType) {
		 if (value1 == null || value2 == null) {
			 throw new RuntimeException("Between values for " + property + " cannot be null");
		 }
		 add(Column.create(name, value1, value2, logic, typeHandler, valueType));
	}
		 
	public SettingSQL andSettingIdIsNull() {
		isnull("setting_id");
		return this;
	}
	
	public SettingSQL andSettingIdIsNotNull() {
		notNull("setting_id");
		return this;
	}
	
	public SettingSQL andSettingIdIsEmpty() {
		empty("setting_id");
		return this;
	}

	public SettingSQL andSettingIdIsNotEmpty() {
		notEmpty("setting_id");
		return this;
	}
      public SettingSQL andSettingIdEqualTo(Integer value) {
          addCriterion("setting_id", value, ConditionMode.EQUAL, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdNotEqualTo(Integer value) {
          addCriterion("setting_id", value, ConditionMode.NOT_EQUAL, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdGreaterThan(Integer value) {
          addCriterion("setting_id", value, ConditionMode.GREATER_THEN, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdGreaterThanOrEqualTo(Integer value) {
          addCriterion("setting_id", value, ConditionMode.GREATER_EQUAL, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdLessThan(Integer value) {
          addCriterion("setting_id", value, ConditionMode.LESS_THEN, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdLessThanOrEqualTo(Integer value) {
          addCriterion("setting_id", value, ConditionMode.LESS_EQUAL, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdBetween(Integer value1, Integer value2) {
    	  addCriterion("setting_id", value1, value2, ConditionMode.BETWEEN, "settingId", "java.lang.Integer", "Float");
    	  return this;
      }

      public SettingSQL andSettingIdNotBetween(Integer value1, Integer value2) {
          addCriterion("setting_id", value1, value2, ConditionMode.NOT_BETWEEN, "settingId", "java.lang.Integer", "Float");
          return this;
      }
        
      public SettingSQL andSettingIdIn(List<Integer> values) {
          addCriterion("setting_id", values, ConditionMode.IN, "settingId", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andSettingIdNotIn(List<Integer> values) {
          addCriterion("setting_id", values, ConditionMode.NOT_IN, "settingId", "java.lang.Integer", "Float");
          return this;
      }
	public SettingSQL andSettingKeyIsNull() {
		isnull("setting_key");
		return this;
	}
	
	public SettingSQL andSettingKeyIsNotNull() {
		notNull("setting_key");
		return this;
	}
	
	public SettingSQL andSettingKeyIsEmpty() {
		empty("setting_key");
		return this;
	}

	public SettingSQL andSettingKeyIsNotEmpty() {
		notEmpty("setting_key");
		return this;
	}
       public SettingSQL andSettingKeyLike(String value) {
    	   addCriterion("setting_key", value, ConditionMode.FUZZY, "settingKey", "java.lang.String", "Float");
    	   return this;
      }

      public SettingSQL andSettingKeyNotLike(String value) {
          addCriterion("setting_key", value, ConditionMode.NOT_FUZZY, "settingKey", "java.lang.String", "Float");
          return this;
      }
      public SettingSQL andSettingKeyEqualTo(String value) {
          addCriterion("setting_key", value, ConditionMode.EQUAL, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyNotEqualTo(String value) {
          addCriterion("setting_key", value, ConditionMode.NOT_EQUAL, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyGreaterThan(String value) {
          addCriterion("setting_key", value, ConditionMode.GREATER_THEN, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyGreaterThanOrEqualTo(String value) {
          addCriterion("setting_key", value, ConditionMode.GREATER_EQUAL, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyLessThan(String value) {
          addCriterion("setting_key", value, ConditionMode.LESS_THEN, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyLessThanOrEqualTo(String value) {
          addCriterion("setting_key", value, ConditionMode.LESS_EQUAL, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyBetween(String value1, String value2) {
    	  addCriterion("setting_key", value1, value2, ConditionMode.BETWEEN, "settingKey", "java.lang.String", "String");
    	  return this;
      }

      public SettingSQL andSettingKeyNotBetween(String value1, String value2) {
          addCriterion("setting_key", value1, value2, ConditionMode.NOT_BETWEEN, "settingKey", "java.lang.String", "String");
          return this;
      }
        
      public SettingSQL andSettingKeyIn(List<String> values) {
          addCriterion("setting_key", values, ConditionMode.IN, "settingKey", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingKeyNotIn(List<String> values) {
          addCriterion("setting_key", values, ConditionMode.NOT_IN, "settingKey", "java.lang.String", "String");
          return this;
      }
	public SettingSQL andSettingValueIsNull() {
		isnull("setting_value");
		return this;
	}
	
	public SettingSQL andSettingValueIsNotNull() {
		notNull("setting_value");
		return this;
	}
	
	public SettingSQL andSettingValueIsEmpty() {
		empty("setting_value");
		return this;
	}

	public SettingSQL andSettingValueIsNotEmpty() {
		notEmpty("setting_value");
		return this;
	}
       public SettingSQL andSettingValueLike(String value) {
    	   addCriterion("setting_value", value, ConditionMode.FUZZY, "settingValue", "java.lang.String", "String");
    	   return this;
      }

      public SettingSQL andSettingValueNotLike(String value) {
          addCriterion("setting_value", value, ConditionMode.NOT_FUZZY, "settingValue", "java.lang.String", "String");
          return this;
      }
      public SettingSQL andSettingValueEqualTo(String value) {
          addCriterion("setting_value", value, ConditionMode.EQUAL, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueNotEqualTo(String value) {
          addCriterion("setting_value", value, ConditionMode.NOT_EQUAL, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueGreaterThan(String value) {
          addCriterion("setting_value", value, ConditionMode.GREATER_THEN, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueGreaterThanOrEqualTo(String value) {
          addCriterion("setting_value", value, ConditionMode.GREATER_EQUAL, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueLessThan(String value) {
          addCriterion("setting_value", value, ConditionMode.LESS_THEN, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueLessThanOrEqualTo(String value) {
          addCriterion("setting_value", value, ConditionMode.LESS_EQUAL, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueBetween(String value1, String value2) {
    	  addCriterion("setting_value", value1, value2, ConditionMode.BETWEEN, "settingValue", "java.lang.String", "String");
    	  return this;
      }

      public SettingSQL andSettingValueNotBetween(String value1, String value2) {
          addCriterion("setting_value", value1, value2, ConditionMode.NOT_BETWEEN, "settingValue", "java.lang.String", "String");
          return this;
      }
        
      public SettingSQL andSettingValueIn(List<String> values) {
          addCriterion("setting_value", values, ConditionMode.IN, "settingValue", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingValueNotIn(List<String> values) {
          addCriterion("setting_value", values, ConditionMode.NOT_IN, "settingValue", "java.lang.String", "String");
          return this;
      }
	public SettingSQL andSettingNameIsNull() {
		isnull("setting_name");
		return this;
	}
	
	public SettingSQL andSettingNameIsNotNull() {
		notNull("setting_name");
		return this;
	}
	
	public SettingSQL andSettingNameIsEmpty() {
		empty("setting_name");
		return this;
	}

	public SettingSQL andSettingNameIsNotEmpty() {
		notEmpty("setting_name");
		return this;
	}
       public SettingSQL andSettingNameLike(String value) {
    	   addCriterion("setting_name", value, ConditionMode.FUZZY, "settingName", "java.lang.String", "String");
    	   return this;
      }

      public SettingSQL andSettingNameNotLike(String value) {
          addCriterion("setting_name", value, ConditionMode.NOT_FUZZY, "settingName", "java.lang.String", "String");
          return this;
      }
      public SettingSQL andSettingNameEqualTo(String value) {
          addCriterion("setting_name", value, ConditionMode.EQUAL, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameNotEqualTo(String value) {
          addCriterion("setting_name", value, ConditionMode.NOT_EQUAL, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameGreaterThan(String value) {
          addCriterion("setting_name", value, ConditionMode.GREATER_THEN, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameGreaterThanOrEqualTo(String value) {
          addCriterion("setting_name", value, ConditionMode.GREATER_EQUAL, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameLessThan(String value) {
          addCriterion("setting_name", value, ConditionMode.LESS_THEN, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameLessThanOrEqualTo(String value) {
          addCriterion("setting_name", value, ConditionMode.LESS_EQUAL, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameBetween(String value1, String value2) {
    	  addCriterion("setting_name", value1, value2, ConditionMode.BETWEEN, "settingName", "java.lang.String", "String");
    	  return this;
      }

      public SettingSQL andSettingNameNotBetween(String value1, String value2) {
          addCriterion("setting_name", value1, value2, ConditionMode.NOT_BETWEEN, "settingName", "java.lang.String", "String");
          return this;
      }
        
      public SettingSQL andSettingNameIn(List<String> values) {
          addCriterion("setting_name", values, ConditionMode.IN, "settingName", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andSettingNameNotIn(List<String> values) {
          addCriterion("setting_name", values, ConditionMode.NOT_IN, "settingName", "java.lang.String", "String");
          return this;
      }
	public SettingSQL andBisysIsNull() {
		isnull("bisys");
		return this;
	}
	
	public SettingSQL andBisysIsNotNull() {
		notNull("bisys");
		return this;
	}
	
	public SettingSQL andBisysIsEmpty() {
		empty("bisys");
		return this;
	}

	public SettingSQL andBisysIsNotEmpty() {
		notEmpty("bisys");
		return this;
	}
      public SettingSQL andBisysEqualTo(Integer value) {
          addCriterion("bisys", value, ConditionMode.EQUAL, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysNotEqualTo(Integer value) {
          addCriterion("bisys", value, ConditionMode.NOT_EQUAL, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysGreaterThan(Integer value) {
          addCriterion("bisys", value, ConditionMode.GREATER_THEN, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysGreaterThanOrEqualTo(Integer value) {
          addCriterion("bisys", value, ConditionMode.GREATER_EQUAL, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysLessThan(Integer value) {
          addCriterion("bisys", value, ConditionMode.LESS_THEN, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysLessThanOrEqualTo(Integer value) {
          addCriterion("bisys", value, ConditionMode.LESS_EQUAL, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysBetween(Integer value1, Integer value2) {
    	  addCriterion("bisys", value1, value2, ConditionMode.BETWEEN, "bisys", "java.lang.Integer", "Float");
    	  return this;
      }

      public SettingSQL andBisysNotBetween(Integer value1, Integer value2) {
          addCriterion("bisys", value1, value2, ConditionMode.NOT_BETWEEN, "bisys", "java.lang.Integer", "Float");
          return this;
      }
        
      public SettingSQL andBisysIn(List<Integer> values) {
          addCriterion("bisys", values, ConditionMode.IN, "bisys", "java.lang.Integer", "Float");
          return this;
      }

      public SettingSQL andBisysNotIn(List<Integer> values) {
          addCriterion("bisys", values, ConditionMode.NOT_IN, "bisys", "java.lang.Integer", "Float");
          return this;
      }
	public SettingSQL andRemarkIsNull() {
		isnull("remark");
		return this;
	}
	
	public SettingSQL andRemarkIsNotNull() {
		notNull("remark");
		return this;
	}
	
	public SettingSQL andRemarkIsEmpty() {
		empty("remark");
		return this;
	}

	public SettingSQL andRemarkIsNotEmpty() {
		notEmpty("remark");
		return this;
	}
       public SettingSQL andRemarkLike(String value) {
    	   addCriterion("remark", value, ConditionMode.FUZZY, "remark", "java.lang.String", "Float");
    	   return this;
      }

      public SettingSQL andRemarkNotLike(String value) {
          addCriterion("remark", value, ConditionMode.NOT_FUZZY, "remark", "java.lang.String", "Float");
          return this;
      }
      public SettingSQL andRemarkEqualTo(String value) {
          addCriterion("remark", value, ConditionMode.EQUAL, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkNotEqualTo(String value) {
          addCriterion("remark", value, ConditionMode.NOT_EQUAL, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkGreaterThan(String value) {
          addCriterion("remark", value, ConditionMode.GREATER_THEN, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkGreaterThanOrEqualTo(String value) {
          addCriterion("remark", value, ConditionMode.GREATER_EQUAL, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkLessThan(String value) {
          addCriterion("remark", value, ConditionMode.LESS_THEN, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkLessThanOrEqualTo(String value) {
          addCriterion("remark", value, ConditionMode.LESS_EQUAL, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkBetween(String value1, String value2) {
    	  addCriterion("remark", value1, value2, ConditionMode.BETWEEN, "remark", "java.lang.String", "String");
    	  return this;
      }

      public SettingSQL andRemarkNotBetween(String value1, String value2) {
          addCriterion("remark", value1, value2, ConditionMode.NOT_BETWEEN, "remark", "java.lang.String", "String");
          return this;
      }
        
      public SettingSQL andRemarkIn(List<String> values) {
          addCriterion("remark", values, ConditionMode.IN, "remark", "java.lang.String", "String");
          return this;
      }

      public SettingSQL andRemarkNotIn(List<String> values) {
          addCriterion("remark", values, ConditionMode.NOT_IN, "remark", "java.lang.String", "String");
          return this;
      }
	public SettingSQL andCreatedIsNull() {
		isnull("created");
		return this;
	}
	
	public SettingSQL andCreatedIsNotNull() {
		notNull("created");
		return this;
	}
	
	public SettingSQL andCreatedIsEmpty() {
		empty("created");
		return this;
	}

	public SettingSQL andCreatedIsNotEmpty() {
		notEmpty("created");
		return this;
	}
      public SettingSQL andCreatedEqualTo(java.util.Date value) {
          addCriterion("created", value, ConditionMode.EQUAL, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedNotEqualTo(java.util.Date value) {
          addCriterion("created", value, ConditionMode.NOT_EQUAL, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedGreaterThan(java.util.Date value) {
          addCriterion("created", value, ConditionMode.GREATER_THEN, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedGreaterThanOrEqualTo(java.util.Date value) {
          addCriterion("created", value, ConditionMode.GREATER_EQUAL, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedLessThan(java.util.Date value) {
          addCriterion("created", value, ConditionMode.LESS_THEN, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedLessThanOrEqualTo(java.util.Date value) {
          addCriterion("created", value, ConditionMode.LESS_EQUAL, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedBetween(java.util.Date value1, java.util.Date value2) {
    	  addCriterion("created", value1, value2, ConditionMode.BETWEEN, "created", "java.util.Date", "String");
    	  return this;
      }

      public SettingSQL andCreatedNotBetween(java.util.Date value1, java.util.Date value2) {
          addCriterion("created", value1, value2, ConditionMode.NOT_BETWEEN, "created", "java.util.Date", "String");
          return this;
      }
        
      public SettingSQL andCreatedIn(List<java.util.Date> values) {
          addCriterion("created", values, ConditionMode.IN, "created", "java.util.Date", "String");
          return this;
      }

      public SettingSQL andCreatedNotIn(List<java.util.Date> values) {
          addCriterion("created", values, ConditionMode.NOT_IN, "created", "java.util.Date", "String");
          return this;
      }
}